//
//  ViewController.m
//  Login
//
//  Created by Justsoso on 16/2/19.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *nameTextField;
@property (weak, nonatomic) IBOutlet UITextField *passwordTextField;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)backTop:(id)sender
{
    [self.view endEditing:YES];
}
- (IBAction)loginBtn:(UIButton *)sender
{
    if ([self.nameTextField.text isEqualToString:@"admin"] && [self.passwordTextField.text intValue] == 123456)
    {
        UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"登录成功" message:@"欢迎您,admin!" preferredStyle:UIAlertControllerStyleAlert];
        [self presentViewController:controller animated:YES completion:nil];
        
        UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
        
        [controller addAction:sureAction];
    }
    else
    {
        UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"登录失败" message:@"用户名密码错误，请重新输入" preferredStyle:UIAlertControllerStyleAlert];
        [self presentViewController:controller animated:YES completion:nil];
        
        UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
        
        [controller addAction:sureAction];
    }
}

@end
